Constants
This section describes the constants used by serial endpoints. You can use the constant nameskSerialName
,kSerialPortAName
,kSerialPortBName
, andkSerialABName
when calling theOTCreateConfiguration
function to configure a serial endpoint. This function is described in the chapter "Configuration Management" in this book.
#define kSerialName 'serial' /* Default serial port */ #define kSerialPortAName 'serialA' /* Serial port A */ #define kSerialPortBName 'serialB' /* Serial port B*/ #define kSerialPortABName 'serialAB' /* Serial port AB*/You use the values in the next enumeration to define the type of framing your serial port is using. These values are used in thefCapabilities
field in theOTPortRecord
structure, described in the chapter "Configuration Management" in this book.
enum{ kOTSerialFramingAsync = 0x01, /* Supports asynchronous serial framing */ kOTSerialFramingHDLC = 0x02, /* Supports serial HDLC framing */ kOTSerialFramingSDLC = 0x04, /* Supports serial SDLC framing */ kOTSerialFramingAsyncPackets = 0x08, /* Supports async packet serial mode */}TheOTIoctl
commands use many constants:
kOTSerialSetDTROn = 1 /* Turn the DTR signal on */ kOTSerialSetDTROff = 0 /* Turn the DTR signal off */ kOTSerialSetBreakOn = 0xfffffff /* Turn the break signal on */ kOTSerialSetBreakOff = 0 /* Turn the break signal off */ kOTSerialForceXOffTrue = 1 /* Unconditional set XOFF state */ kOTSerialForceXOffFalse = 0 /* Unconditional clear XOFF state */ kOTSerialSendXOnAlways = 1 /* Always send XON character */ kOTSerialSendXOnIfXOffTrue= 0 /* Send XON char only if XOFF state */ kOTSerialSendXOffAlways = 1 /* Always send XOFF character */ kOTSerialSendXOffIfXOnTrue= 0 /* Send XOFF char only if XON state */This define statement, which is identical to the C++ inline function Open Transport provides for this task, creates the 4-byte option value you use for theSERIAL_OPT_HANDSHAKE
option:
#define SerialHandshakeData(type, onChar, offChar)\ ((((UInt32)type) << 16) | (((UInt32)onChar) << 8) | offChar)These define statements, which are similar to the C++ inline functions Open Transport provides for these tasks, set the correct placement for the characters you use with theSERIAL_OPT_ERRORCHARACTER
option:
#define OTSerialSetErrorCharacter(rep) \ ((rep) & 0xff) #define OTSerialSetErrorCharacterWithAlternate(rep, alternate) \ ((((rep) & 0xff) | (((alternate) & 0xff) << 8)) | 0x80000000L)This enumeration lists the default values for serial endpoint providers:
enum{ kOTSerialDefaultBaudRate= 19200, /* 19200 baud rate */ kOTSerialDefaultDataBits= 8, /* 8 data bits */ kOTSerialDefaultStopBits= 10, /* 1 stop bit */ kOTSerialDefaultParity= kOTSerialNoParity, /* no parity */ kOTSerialDefaultHandshake= 0, /* no handshaking */ kOTSerialDefaultOnChar= ('Q' & ~0x40),/* XON = Control-Q */ kOTSerialDefaultOffChar= ('S' & ~0x40),/* XOFF = Control-S */ kOTSerialDefaultSndBufSize= 128, /* send buffer = 128 characters */ kOTSerialDefaultRcvBufSize= 128, /* recv buffer = 128 characters */ kOTSerialDefaultSndLoWat= 96, /* send low-water mark */ kOTSerialDefaultRcvLoWat= 1 /* recv low-water mark */ kOTSerialDefaultRcvTimeout= 10 /* recv timeout, in seconds*/ };